package gang.org.springframework.boot.autoconfigure.web.servlet;

import gang.org.springframework.boot.autoconfigure.GangAutoConfiguration;
import gang.org.springframework.framework.annotation.GBean;
import gang.org.springframework.framework.annotation.GConfiguration;
import gang.org.springframework.framework.web.servlet.GangDispatcherServlet;

/**
 * @Author：gang.chen
 * @Date：2023/10/13 9:08
 */
@GangAutoConfiguration
public class GangDispatcherServletAutoConfiguration {

    public static final String DEFAULT_DISPATCHER_SERVLET_BEAN_NAME = "dispatcherServlet";

    @GConfiguration
    public static class GangDispatcherServletConfiguration{

        @GBean
        public GangDispatcherServlet dispatcherServlet(Object webMvcProperties){
            GangDispatcherServlet dispatcherServlet = new GangDispatcherServlet();

            //TODO

            //TODO
            return dispatcherServlet;
        }
    }


    @GConfiguration
    public static class GangDispatcherServletRegistrationConfiguration{

        @GBean
        public GangDispatcherServletRegistrationBean dispatcherServletRegistration(GangDispatcherServlet dispatcherServlet, Object webMvcProperties, Object multipartConfig)
        {
            //TODO
            GangDispatcherServletRegistrationBean registration = new GangDispatcherServletRegistrationBean(dispatcherServlet, "/");

            registration.setName(DEFAULT_DISPATCHER_SERVLET_BEAN_NAME);
            //TODO

            return registration;
        }

    }
}
